<template>
  <div class="transactionCommissionNewCheck">
    <!-- 编辑 -->
    <div v-show="edit == 1">
      <div v-show="!print">
        <el-breadcrumb separator="/" style="font-size:16px;height:30px;">
          <el-breadcrumb-item :to="{ path: '/transactionAndCommission' }">交易及佣金</el-breadcrumb-item>
          <el-breadcrumb-item>{{checkOrEdit == 1 ? '查看':'编辑'}}</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="top">
          <span class="one">
            <span>批次号：</span>
            <span>{{topData.brokerageNode}}</span>
          </span>
          <span class="one">
            <span>城市：</span>
            <span>{{topData.cityName}}</span>
          </span>
          <span class="one">
            <span>楼盘：</span>
            <span>{{topData.devName}}</span>
          </span>
          <span class="one" v-show="checkOrEdit == 1">
            <span>本次好生活总收入金额：</span>
            <span>{{topData.brokerageTotal}}</span>
          </span>
        </div>
        <div v-if="checkOrEdit == 2">
          <el-button class="pri" type="primary" size="mini" @click="handlePrint">打印</el-button>
        </div>
        <el-table :data="listData" border style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
          <el-table-column align="center" fixed width="55" type="selection" v-if="checkOrEdit == 2"></el-table-column>
          <el-table-column align="center" fixed  label="序号" type="index" width="60"></el-table-column>
          <el-table-column align="center" prop="cityName" label="城市" width="150"></el-table-column>
          <el-table-column align="center" prop="customerName" label="客户姓名" width="150"></el-table-column>
          <el-table-column align="center" prop="customerPhone" label="手机号" width="150" :formatter="initPhone"></el-table-column>
          <el-table-column align="center" prop="devName" label="楼盘名称" width="300"></el-table-column>
          <el-table-column align="center" prop="houseNum" label="房间号" width="200"></el-table-column>
          <el-table-column align="center" prop="houseArea" label="面积" width="120"></el-table-column>
          <el-table-column align="center" prop="nodeName" label="客户状态" width="120"> </el-table-column>
          <el-table-column align="center" prop="dealAmount" label="成交价" width="150" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="devAmount" label="房款" width="150" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="packageName" label="套餐名称" width="180">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="handleCheckRule(scope.row)" :disabled="scope.row.packageName?false:true">{{scope.row.packageName}}</el-button>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="amountTotal" label="好生活总收入金额" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="frontAmount" label="前佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="afterAmount" label="后佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="awardAmountTotal" label="经纪人奖励" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="awardSource" label="奖励来源" width="180">
            <template slot-scope="scope">
              <span v-show="scope.row.awardSource == 1">开发商-返还款</span>
              <span v-show="scope.row.awardSource == 2">开发商-回款</span>
              <span v-show="scope.row.awardSource == 5">前佣-经纪人分佣</span>
              <span v-show="scope.row.awardSource == 6">后佣-经纪人分佣</span>
              <span v-show="!scope.row.awardSource">-</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="brokerAmount" label="渠道佣金" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAmountFront" label="渠道前佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAmountAfter" label="渠道后佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAwardAmount" label="渠道经纪人奖励" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="companyName" label="渠道公司" width="180">
            <template slot-scope="scope">
              {{scope.row.companyName?scope.row.companyName:'-'}}
            </template>
          </el-table-column>
          <el-table-column align="center" prop="dealTime" label="交易时间" width="180" :formatter="initTime"></el-table-column>
        </el-table>
        <div class="pagination" v-show="checkOrEdit == 1">
          <el-pagination
            background
            @size-change="handleSizeChangeEdit"
            @current-change="handleCurrentChangeEdit"
            :current-page.sync="pageDataEdit.pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageDataEdit.pageSize"
            layout="total, sizes, prev, pager, next"
            :total="totalSizeEdit">
          </el-pagination>
        </div>
        <div class="part" v-show="(yongjinList.length  && checkOrEdit == 1 ) || checkOrEdit == 2">
          <div class="txt">佣金确认表：</div>
          <div class="content">
            <upload :multiple="true" ref="upload4" :fileList="yongjinList" v-if="checkOrEdit == 2"/>
            <upload :multiple="true" ref="upload4" :fileList="yongjinList" v-else readonly/>
          </div>
        </div>
        <div class="step" v-if="checkOrEdit == 1">
          <el-steps :space="300" :active="activeNum" finish-status="success">
            <el-step title="运营提交审核"></el-step>
            <el-step title="开发商审核"></el-step>
          </el-steps>
        </div>
        <div class="btn" v-if="checkOrEdit == 2">
          <el-button type="primary" size="mini" @click="handleAdd">继续添加</el-button>
          <el-button type="primary" size="mini" @click="handleSave(0)">保存</el-button>
          <el-button type="primary" size="mini" @click="handleSave(1)">保存并提交审核</el-button>
        </div>
        <div class="part">
          <div class="txt">{{checkOrEdit == 2 ?'操作':'审核'}}记录：</div>
          <div class="content">
            <el-table :data="recordList" border style="width: 781px">
              <el-table-column align="center" prop="auditStatusNote" label="操作" width="150"></el-table-column>
              <el-table-column align="center" prop="submitPersonName" label="操作人" width="150"></el-table-column>
              <el-table-column align="center" prop="roleTypeNote" label="角色" width="150"></el-table-column>
              <el-table-column align="center" prop="createTime" label="时间" width="180"></el-table-column>
              <el-table-column align="center" prop="remark" label="理由" width="150"></el-table-column>
            </el-table>
          </div>
        </div>
      </div>
      <orderPrint  ref="orderPrint" v-show="print == 'print'" v-on:print="close" />
    </div>
    <!-- 继续添加 -->
    <div v-show="edit == 0">
      <div class="transactionCommissionNew">
        <el-breadcrumb separator="/" style="font-size:16px;height:30px;">
          <el-breadcrumb-item :to="{ path: '/transactionAndCommission' }">交易及佣金</el-breadcrumb-item>
          <el-breadcrumb-item>{{checkOrEdit == 1 ? '查看':'编辑'}}</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="filter">
          <el-form :inline="true" class="demo-form-inline">
            <el-form-item label="城市：">
              <el-select v-model="cityId" placeholder="请选择城市" size="mini" filterable clearable @change="getCityId">
                <el-option
                  :label="item.city"
                  :value="item.cityId"
                  v-for="(item,idx) in cityList"
                  :key="idx"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="楼盘：">
              <el-select v-model="devId" placeholder="请选择楼盘" size="mini" filterable clearable>
                <el-option
                  :label="item.devName"
                  :value="item.devId"
                  v-for="(item,idx) in devList"
                  :key="idx"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户状态：">
              <el-select v-model="customerStatusId" placeholder='全部' size="mini">
                <el-option
                  :label="item.name"
                  :value="item.id"
                  v-for="(item,idx) in customerStatusList"
                  :key="idx"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户姓名：">
              <el-input v-model="customerName" placeholder="请输入客户姓名" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="渠道公司名称：">
              <el-input v-model="companyName" placeholder="请输入渠道公司名称" size="mini"></el-input>
            </el-form-item>
            <el-form-item style="margin-top:-2px;margin-left:10px;">
              <el-button type="primary" @click="checkList" size="mini" id="monitorEnter">查询</el-button>
            </el-form-item>
          </el-form>
        </div>
        <el-table
          :data="listDataNew"
          border
          style="width: 100%"
          @selection-change="handleSelectionChangeNew"
        >
          <el-table-column align="center" fixed type="selection" width="55"></el-table-column>
          <el-table-column align="center" fixed label="序号" type="index" width="60"></el-table-column>
          <el-table-column align="center" prop="cityName" label="城市" width="150"></el-table-column>
          <el-table-column align="center" prop="customerName" label="客户姓名" width="150"></el-table-column>
          <el-table-column
            align="center"
            prop="customerPhone"
            label="手机号"
            width="150"
            :formatter="initPhone"
          ></el-table-column>
          <el-table-column align="center" prop="devName" label="楼盘名称" width="300"></el-table-column>
          <el-table-column align="center" prop="houseNum" label="房间号" width="200"></el-table-column>
          <el-table-column align="center" prop="houseArea" label="面积" width="120"></el-table-column>
          <el-table-column align="center" prop="nodeName" label="客户状态" width="120"></el-table-column>
          <el-table-column align="center" prop="dealAmount" label="成交价" width="150" :formatter="initMoney"></el-table-column>
          <el-table-column
            align="center"
            prop="devAmount"
            label="房款"
            width="150"
            :formatter="initMoney"
          ></el-table-column>
          <el-table-column align="center" prop="packageName" label="套餐名称" width="180">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="handleCheckRule(scope.row)" :disabled="scope.row.packageName?false:true">{{scope.row.packageName}}</el-button>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="amountTotal"
            label="好生活总收入金额"
            width="180"
            :formatter="initMoney"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="frontAmount"
            label="前佣"
            width="180"
            :formatter="initMoney"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="afterAmount"
            label="后佣"
            width="180"
            :formatter="initMoney"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="awardAmountTotal"
            label="经纪人奖励"
            width="180"
            :formatter="initMoney"
          ></el-table-column>
          <el-table-column align="center" prop="awardSource" label="奖励来源" width="180">
            <template slot-scope="scope">
              <span v-show="scope.row.awardSource == 1">开发商-返还款</span>
              <span v-show="scope.row.awardSource == 2">开发商-回款</span>
              <span v-show="scope.row.awardSource == 5">前佣-经纪人分佣</span>
              <span v-show="scope.row.awardSource == 6">后佣-经纪人分佣</span>
              <span v-show="!scope.row.awardSource">-</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="brokerAmount" label="渠道佣金" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAmountFront" label="渠道前佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAmountAfter" label="渠道后佣" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="brokerAwardAmount" label="渠道经纪人奖励" width="180" :formatter="initMoney"></el-table-column>
          <el-table-column align="center" prop="companyName" label="渠道公司" width="180">
            <template slot-scope="scope">
              {{scope.row.companyName?scope.row.companyName:'-'}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="dealTime"
            label="交易时间"
            width="180"
            :formatter="initTime"
          ></el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageData.pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageData.pageSize"
            layout="total, sizes, prev, pager, next"
            :total="totalSize"
          ></el-pagination>
        </div>
        <div style="text-align:center;margin-top:40px;margin-bottom:30px;">
          <!-- <el-button type="primary" @click="handleCancle" size="mini">返回</el-button> -->
          <el-button type="primary" @click="handleAddBatch(1)" size="mini">添加到批次</el-button>
          <el-button type="primary" @click="handleAddBatch(2)" size="mini">添加到批次到下一步</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from "@/api/apiPath"
import util from '@/common/utils'
import upload from '@/components/common/Upload'
import orderPrint from './orderPrint'
export default {
  name:"transactionCommissionNewCheck",
  components: {
    upload,
    orderPrint
  },
  data() {
    return {
      cityList: [],
      cityId: "",
      devList: [],
      devId: "",
      customerStatusId: undefined,
      customerStatusList: [
        { name: "全部", id: "" },
        { name: "认购", id: "PURCHASE" },
        { name: "草签", id: "INITIAL" },
        { name: "签约", id: "SIGN" },
        { name: "退认购", id: "REFUND_PURCHASE" }
      ],
      customerName: "",
      companyName:'',
      listDataNew: [],
      multipleSelectionEdit: [],
      multipleSelectionAllEdit:[],
      tempcompanyInfoIdEdit:[],
      idKeyNew: "companyInfoId",
      edit:1,
      print:'',
      activeNum:undefined,
      listData: [],
      recordList:[],
      multipleSelection:[],
      yongjinList:[],
      checkOrEdit:window.sessionStorage.getItem('checkOrEdit'),
      topData:{
        brokerageNode:'',
        cityName:'',
        devName:'',
        brokerageTotal:''
      },
      id:[],
      totalSize:0,
      totalSizeEdit:0,
      pageData:{
        pageNum:1,
        pageSize:10
      },
      pageDataEdit:{
        pageNum:1,
        pageSize:10
      },
      yongjinData:{
        pdfarr:[],
        pictures:[],
      }
    }
  },
  mounted() {
  },
  created() {
    this.getCityList()
    this.getDevList()
    this.getActiveNum()
    if(window.sessionStorage.getItem('checkOrEdit') == 1){
      this.getOrderList()
    }else if(window.sessionStorage.getItem('checkOrEdit') == 2){
      this.getEditOrderList()
    }
    this.orderList(this.id)
    this.getRemarkList()
    window.localStorage.removeItem("tempcompanyInfoIdEdit")

  },
  methods: {
    checkList(){
      if(window.localStorage.getItem("tempcompanyInfoIdEdit")){
        this.id = window.localStorage.getItem("tempcompanyInfoIdEdit").split(",")
      }
      this.pageData.pageNum = 1
      this.orderList(this.id)
    },
    // 添加到批次
    handleAddBatch(val) {
      let multipleSelectionLength = this.multipleSelection.length
      this.multipleSelection = this.multipleSelection.concat(this.multipleSelectionEdit)

      if (window.localStorage.getItem("tempcompanyInfoIdEdit")) {
        let tempcompanyInfoIdEdit = window.localStorage
          .getItem("tempcompanyInfoIdEdit")
          .split(",")
        window.localStorage.setItem(
          "tempcompanyInfoIdEdit",
          tempcompanyInfoIdEdit.concat(this.tempcompanyInfoIdEdit)
        )
      } else {
        window.localStorage.setItem(
          "tempcompanyInfoIdEdit",
          this.tempcompanyInfoIdEdit
        )
      }
      if(val == 1){
        if(this.tempcompanyInfoIdEdit.length == 0){
          this.$message({
            type: "warning",
            message: "至少选择一条订单并添加到批次"
          })
          return
        }
        // 被选中的楼盘id
        let devId = []
        this.multipleSelection.forEach(item=>{
          devId.push(item.devId)
        })
        if(Array.from(new Set(devId)).length!=1){
          this.$message.error('请选择同一楼盘的订单')
          this.multipleSelection = this.multipleSelection.splice(0,multipleSelectionLength)
          return
        }
        this.listData = this.multipleSelection
        this.id = window.localStorage.getItem("tempcompanyInfoIdEdit").split(",")
        this.orderList(this.id)
        this.$message({
          type:'success',
          message:'成功添加'+this.tempcompanyInfoIdEdit.length+'条信息到批次'
        })
      }else if (val == 2){
        console.log(this.tempcompanyInfoIdEdit.length);
        if(this.tempcompanyInfoIdEdit.length == 0 ){
          if(this.multipleSelection.length == 0){
            this.$message({
              type: "warning",
              message: "至少选择一条订单并添加到批次"
            })
            return
          }
          this.edit = 1
        }else{
          // 被选中的楼盘id
          let devId = []
          this.multipleSelection.forEach(item=>{
            devId.push(item.devId)
          })
          if(Array.from(new Set(devId)).length!=1){
            this.$message.error('请选择同一楼盘的订单')
            this.multipleSelection = this.multipleSelection.splice(0,multipleSelectionLength)
            return
          }
          this.listData = this.multipleSelection
          this.edit = 1
          this.id = window.localStorage.getItem("tempcompanyInfoIdEdit").split(",");
          this.orderList(this.id)
          this.$message({
            type:'success',
            message:'成功添加'+this.tempcompanyInfoIdEdit.length+'条信息到批次'
          })
        }
      }
      this.toggleSelection(this.multipleSelection)
    },
    // 订单总列表
    orderList(tempcompanyInfoId) {
      let temId = [];
      if (tempcompanyInfoId == []) {
        temId = [];
      } else {
        temId = tempcompanyInfoId
      }
      this.axios
        .post(api.getBrokerageCompanyInfoList, {
          pageNum: this.pageData.pageNum,
          pageSize: this.pageData.pageSize,
          devId: this.devId,
          cityId: this.cityId,
          customerName: this.customerName,
          companyName: this.companyName,
          followType: this.customerStatusId,
          tempcompanyInfoId: temId
        })
        .then(res => {
          if (res.data.code == 200) {
            this.totalSize = res.data.data.total;
            this.listDataNew = res.data.data.rows;
          }
        });
    },
    // 继续添加-多选
    handleSelectionChangeNew(val) {
      this.multipleSelectionEdit = val;
      setTimeout(() => {
        this.changePageCoreRecordDataNew();
      }, 300);
    },
    // 记忆选择核心方法
    changePageCoreRecordDataNew() {
      // 标识当前行的唯一键的名称
      let idKeyNew = this.idKeyNew;
      let that = this;
      this.multipleSelectionAllEdit = this.multipleSelectionEdit;
      // 总选择里面的key集合
      let selectAllIds = [];
      this.multipleSelectionAllEdit.forEach(row => {
        selectAllIds.push(row[idKeyNew]);
      });
      // console.log("总选择的key", selectAllIds);
      this.tempcompanyInfoIdEdit = [];
      // 获取当前页选中的id
      this.multipleSelectionEdit.forEach(row => {
        this.tempcompanyInfoIdEdit.push(row[idKeyNew]);
        // 如果总选择里面不包含当前页选中的数据，那么就加入到总选择集合里
        if (selectAllIds.indexOf(row[idKeyNew]) < 0) {
          that.multipleSelectionAllEdit.push(row);
        }
      });
      // console.log("当前也的选中id", this.tempcompanyInfoIdEdit);
      let noSelectIds = [];
      // 得到当前页没有选中的id
      this.listDataNew.forEach(row => {
        if (this.tempcompanyInfoIdEdit.indexOf(row[idKeyNew]) < 0) {
          noSelectIds.push(row[idKeyNew]);
        }
      });
      noSelectIds.forEach(id => {
        if (selectAllIds.indexOf(id) >= 0) {
          for (let i = 0; i < that.multipleSelectionAllEdit.length; i++) {
            if (that.multipleSelectionAllEdit[i][idKeyNew] == id) {
              // 如果总选择中有未被选中的，那么就删除这条
              that.multipleSelectionAllEdit.splice(i, 1);
              break;
            }
          }
        }
      });
    },
    // 城市列表
    getCityList() {
      this.axios.post(api.CITYLIST).then(res => {
        if (res.data.code == 200) {
          this.cityList = res.data.data.cityList;
        }
      });
    },
    getCityId(val){
      this.getDevList(val)
      this.devId = ''
    },
    // 楼盘列表
    getDevList(val) {
      this.axios.post(api.queryAllDevList, {
        cityId:val
      }).then(res => {
        if (res.data.code == 200) {
          this.devList = res.data.data;
        }
      });
    },
    close(val) {
      console.log(val);
      this.print = "";
    },
    // 获取审核状态决定步骤条状态
    getActiveNum(){
      let auditStatus = JSON.parse(window.sessionStorage.getItem('row')).auditStatus
      if(auditStatus == 0 || auditStatus == 3){
        this.activeNum = 0
      }else if(auditStatus == 1 ){
        this.activeNum = 1
      }else if(auditStatus == 2 ){
        this.activeNum = 2
      }
    },
    initPhone(row, column, cellValue, index){
      return util.formatPhoneNumber(cellValue)
    },
    initMoney(row, column, cellValue, index){
      return util.formatMoney(cellValue)
    },
    initTime(row, column, cellValue, index){
      return util.getTimeString(cellValue)
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 编辑-
    handleSizeChangeEdit(val) {
      this.pageDataEdit.pageSize = val
      if(window.sessionStorage.getItem('checkOrEdit') == 1){
        this.getOrderList()
      }else if(window.sessionStorage.getItem('checkOrEdit') == 2){
        this.getEditOrderList()
      }
    },
    // 编辑
    handleCurrentChangeEdit(val) {
      if(window.sessionStorage.getItem('checkOrEdit') == 1){
        this.getOrderList()
      }else if(window.sessionStorage.getItem('checkOrEdit') == 2){
        this.getEditOrderList()
      }
    },
    // 继续添加
    handleSizeChange(val) {
      this.pageData.pageSize = val
      this.orderList(this.id)
    },
    // 继续添加
    handleCurrentChange(val) {
      this.orderList(this.id)
    },
    // 查看佣金套餐规则
    handleCheckRule(row){
      let route = this.$router.resolve({path:'/ruleDetail',query:{
        customerFollowId:row.customerFollowId,
        // brokerageNode:row.brokerageNode,
        // checkOrEdit:this.checkOrEdit
      }})
      window.open(route.href,'_blank')
    },
    // 查看-订单列表
    getOrderList(){
      this.axios.post(api.getLookList,{
        batchId:JSON.parse(window.sessionStorage.getItem('row')).id,
        pageNum:this.pageDataEdit.pageNum,
        pageSize:this.pageDataEdit.pageSize
      }).then(res=>{
        console.log(res)
        if(res.data.code == 200){
          this.totalSizeEdit = res.data.data.total
          this.listData = res.data.data.rows
          this.topData.brokerageNode = JSON.parse(window.sessionStorage.getItem('row')).batchCode
          this.topData.cityName = this.listData[0].cityName
          this.topData.devName = this.listData[0].devName
          this.topData.brokerageTotal = util.formatMoney(res.data.data.brokerageTotal)
          // 佣金确认表
          this.yongjinList = []
          if(this.listData[0].pictureAddress){
            if(JSON.parse(this.listData[0].pictureAddress).pictures){
              JSON.parse(this.listData[0].pictureAddress).pictures.forEach(item=>{
                this.yongjinList.push(item.url)
              })
            }
            if(JSON.parse(this.listData[0].pictureAddress).pdfarr){
              JSON.parse(this.listData[0].pictureAddress).pdfarr.forEach(item=>{
                this.yongjinList.push(item.url)
              })
            }
          }
        }
      })
    },

    toggleSelection(rows) {
      if (rows) {
        this.$nextTick(()=>{
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row,true)
          })
        })
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    // 编辑-订单列表
    getEditOrderList(){
      this.axios.post(api.getConfirmEditList,{
        devId:JSON.parse(window.sessionStorage.getItem('row')).devId,
        cityId:JSON.parse(window.sessionStorage.getItem('row')).cityId,
        batchId:JSON.parse(window.sessionStorage.getItem('row')).id,
        pageNum:this.pageDataEdit.pageNum,
        pageSize:this.pageDataEdit.pageSize
      }).then(res=>{
        console.log(res);
        if(res.data.code == 200){
          // this.totalSizeEdit = res.data.data.total
          this.listData = res.data.data.rows
          this.topData.brokerageNode = JSON.parse(window.sessionStorage.getItem('row')).batchCode
          this.topData.cityName = JSON.parse(window.sessionStorage.getItem('row')).cityName
          this.topData.devName = JSON.parse(window.sessionStorage.getItem('row')).devName
          this.multipleSelection = []
          this.multipleSelection = this.listData
          this.toggleSelection(this.multipleSelection)
          // 佣金确认表
          this.yongjinList = []
          if(res.data.data.pictureAddress){
            if(JSON.parse(res.data.data.pictureAddress).pictures){
              JSON.parse(res.data.data.pictureAddress).pictures.forEach(item=>{
                this.yongjinList.push(item.url)
              })
            }
            if(JSON.parse(res.data.data.pictureAddress).pdfarr){
              JSON.parse(res.data.data.pictureAddress).pdfarr.forEach(item=>{
                this.yongjinList.push(item.url)
              })
            }
          }
        }
      })
    },
    // 下载
    handleDown(val){
      window.open(val)
    },
    // 审核记录
    getRemarkList(){
      this.axios.post(api.remarkList,{
        batchId:JSON.parse(window.sessionStorage.getItem('row')).id
      }).then(res=>{
        if(res.data.code == 200){
          this.recordList = res.data.data
          this.recordList.forEach(item=>{
            item.createTime = util.getTimeString(item.createTime)
          })
        }
      })
    },
    // 打印
    handlePrint(){
      if(this.multipleSelection.length == 0){
        this.$message({
          type:'warning',
          message:'请选择订单'
        })
        return
      }
      window.sessionStorage.setItem('tal',JSON.stringify(this.multipleSelection))
      // this.$router.push({path:'/orderPrint'})
      this.print = "print";
      this.$refs.orderPrint.getDevInfo()
    },
    handleAdd(){
      this.edit = 0
    },
    // 保存
    handleSave(val){
      if(this.multipleSelection.length == 0){
        this.$message({
          type:'warning',
          message:'请选择订单'
        })
        return
      }else{
        this.multipleSelection.forEach((item,index)=>{
          item.dataIndex = index+1
        })
      }
      Promise.all([
          this.$refs.upload4.submit(),
        ]).then(res=>{
        if (res[0].length < 1) {
          this.$message({
              message: '佣金确认表不能为空',
              type: 'warning'
          });
          return
        }
        // 佣金确认表
        this.yongjinData.pdfarr = []
        this.yongjinData.pictures = []
        res[0].forEach(item=>{
          let suffix = item.substring(item.lastIndexOf('.')+1,item.length)
          if(suffix == 'pdf'){
            this.yongjinData.pdfarr.push({
              name:item.substring(item.lastIndexOf('/')+1,item.length),
              url:item
            })
          }else{
            this.yongjinData.pictures.push({
              name:item.substring(item.lastIndexOf('/')+1,item.length),
              url:item
            })
          }
        })
        this.axios.post(api.save,{
          auditStatus:val,
          batchId:JSON.parse(window.sessionStorage.getItem('row')).id,
          data:this.multipleSelection,
          pictureAddress:this.yongjinData,// 佣金确认表
        }).then(res=>{
          if(res.data.code == 200){
            this.$router.push({path:"/transactionAndCommission"})
          }
        })

      })
    }
  },
  computed: {}
}
</script>
<style lang="stylus" scoped>
  .transactionCommissionNewCheck {
    .block {
      margin-top: 15px;
    }
    .top{
      margin-bottom :15px;
      font-size :14px;
      color :#909399;
    }
    .one{
      margin-right :50px;
    }
    .pri{
      float :right;
      margin-bottom:15px;
    }
    .part{
      margin-top :30px;
      display:flex;
      font-size :14px;
      color :#909399;
    }
    .txt{
      width :200px;
    }
    .content{
      flex:1;
    }
    .pagination{
      margin-top :20px;
    }
    .content .contentImg{
      width:100%;
    }
    .img{
      display:inline-block;
      width:195px;
      height :150px;
    }
    .img img{
      display:inline-block;
      width:100%;
      height :100%;
    }
    .btn{
      margin-top :40px;
      margin-bottom :40px;
      padding-left :200px;
    }
    .step{
      margin-top :30px;
      margin-left :200px;
      font-size :14px;
      color :#909399;
    }
  }
</style>
